home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / MCC_TheBar / Developer / C / Examples / demo8.c < prev    next >
Encoding:
C/C++ Source or Header  |  2004-01-31  |  7.3 KB  |  169 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/TheBar_mcc.h>
  7. #include <string.h>
  8. #include <stdio.h>
  9. #include "Symbols.h"
  10.  
  11. /***********************************************************************/
  12.  
  13. long __stack = 8192;
  14. struct Library *MUIMasterBase;
  15.  
  16. /***********************************************************************/
  17.  
  18. #ifndef MAKE_ID
  19. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  20. #endif
  21.  
  22. /***********************************************************************/
  23.  
  24. #define PIC_WIDTH  16
  25. #define PIC_HEIGHT 16
  26. #define PIC(x,y)   (x)*PIC_WIDTH, (y)*PIC_HEIGHT, PIC_WIDTH, PIC_HEIGHT
  27.  
  28. struct MUIS_TheBar_Brush brush0 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 7,0), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS};
  29. struct MUIS_TheBar_Brush brush1 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC(14,0), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS};
  30. struct MUIS_TheBar_Brush brush2 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 1,1), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS};
  31. struct MUIS_TheBar_Brush brush3 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC(10,1), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS};
  32. struct MUIS_TheBar_Brush brush4 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 2,2), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS};
  33. struct MUIS_TheBar_Brush brush5 = {Symbols_Data, SYMBOLS_WIDTH, SYMBOLS_HEIGHT, SYMBOLS_TOTALWIDTH, PIC( 1,0), Symbols_Colors, SYMBOLS_NUMCOLORS, SYMBOLS_TRCOLOR, SYMBOLS_CSIZE, SYMBOLS_FLAGS};
  34.  
  35. struct MUIS_TheBar_Brush *brushes[] = {&brush0,&brush1,&brush2,&brush3,&brush4,&brush5,(APTR)-1};
  36.  
  37. struct MUIS_TheBar_Button buttons[] =
  38. {
  39.     {0, 0, "_Face",  "Just a face."     },
  40.     {1, 1, "_Mouse", "Your mouse."      },
  41.     {2, 2, "_Tree",  "Mind takes place."},
  42.     {MUIV_TheBar_BarSpacer, -1},
  43.     {3, 3, "_Help",  "Read this!."      },
  44.     {4, 4, "_ARexx", "ARexx for ever!." },
  45.     {5, 5, "_Host",  "Your computer."   },
  46.     {MUIV_TheBar_End},
  47. };
  48.  
  49. /***********************************************************************/
  50.  
  51. char *appareances[] = {"Images and text","Images","Text",NULL};
  52. char *labelPoss[] = {"Bottom","Top","Right","Left",NULL};
  53.  
  54. int
  55. main(int argc,char **argv)
  56. {
  57.     int res;
  58.  
  59.     if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  60.     {
  61.         Object *app, *win, *sb, *appareance, *labelPos, *borderless, *sunny, *raised, *scaled, *update;
  62.  
  63.         if (app = ApplicationObject,
  64.                 MUIA_Application_Title,         "TheBar Demo6",
  65.                 MUIA_Application_Version,       "$VER: TheBarDemo6 1.0 (24.6.2003)",
  66.                 MUIA_Application_Copyright,     "Copyright 2003 by Alfonso Ranieri",
  67.                 MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  68.                 MUIA_Application_Description,  "TheBar example",
  69.                 MUIA_Application_Base,         "THEBAREXAMPLE",
  70.  
  71.                 SubWindow, win = WindowObject,
  72.                     MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  73.                     MUIA_Window_Title,          "TheBar Demo6",
  74.                     WindowContents, VGroup,
  75.                         Child, sb = TheBarObject,
  76.                             GroupFrame,
  77.                             MUIA_Group_Horiz,       TRUE,
  78.                             MUIA_TheBar_EnableKeys, TRUE,
  79.                             MUIA_TheBar_Buttons,    buttons,
  80.                             MUIA_TheBar_Images,     brushes,
  81.                         End,
  82.                         Child, VGroup,
  83.                             GroupFrameT("Settings"),
  84.                             Child, HGroup,
  85.                                 Child, Label2("Appareance"),
  86.                                 Child, appareance = MUI_MakeObject(MUIO_Cycle,NULL,appareances),
  87.                                 Child, Label2("Label pos"),
  88.                                 Child, labelPos = MUI_MakeObject(MUIO_Cycle,NULL,labelPoss),
  89.                             End,
  90.                             Child, HGroup,
  91.                                 Child, HSpace(0),
  92.                                 Child, Label1("Borderless"),
  93.                                 Child, borderless = MUI_MakeObject(MUIO_Checkmark,NULL),
  94.                                 Child, HSpace(0),
  95.                                 Child, Label1("Sunny"),
  96.                                 Child, sunny = MUI_MakeObject(MUIO_Checkmark,NULL),
  97.                                 Child, HSpace(0),
  98.                                 Child, Label1("Raised"),
  99.                                 Child, raised = MUI_MakeObject(MUIO_Checkmark,NULL),
  100.                                 Child, HSpace(0),
  101.                                 Child, Label1("Scaled"),
  102.                                 Child, scaled = MUI_MakeObject(MUIO_Checkmark,NULL),
  103.                                 Child, HSpace(0),
  104.                             End,
  105.                         End,
  106.                         Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  107.                     End,
  108.                 End,
  109.             End)
  110.         {
  111.             ULONG sigs = 0, id;
  112.  
  113.             DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  114.             DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  115.  
  116.             set(win,MUIA_Window_Open,TRUE);
  117.  
  118.             while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  119.             {
  120.                 if (id==TAG_USER)
  121.                 {
  122.                     ULONG appareanceV, labelPosV, borderlessV, sunnyV, raisedV, scaledV;
  123.  
  124.                     get(appareance,MUIA_Cycle_Active,&appareanceV);
  125.                     get(labelPos,MUIA_Cycle_Active,&labelPosV);
  126.                     get(borderless,MUIA_Selected,&borderlessV);
  127.                     get(sunny,MUIA_Selected,&sunnyV);
  128.                     get(raised,MUIA_Selected,&raisedV);
  129.                     get(scaled,MUIA_Selected,&scaledV);
  130.  
  131.                     SetAttrs(sb,MUIA_TheBar_ViewMode,   appareanceV,
  132.                                 MUIA_TheBar_LabelPos,   labelPosV,
  133.                                 MUIA_TheBar_Borderless, borderlessV,
  134.                                 MUIA_TheBar_Sunny,      sunnyV,
  135.                                 MUIA_TheBar_Raised,     raisedV,
  136.                                 MUIA_TheBar_Scaled,     scaledV,
  137.                                 TAG_DONE);
  138.                 }
  139.  
  140.                 if (sigs)
  141.                 {
  142.                     sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  143.                     if (sigs & SIGBREAKF_CTRL_C) break;
  144.                 }
  145.             }
  146.  
  147.             MUI_DisposeObject(app);
  148.  
  149.             res = RETURN_OK;
  150.         }
  151.         else
  152.         {
  153.             printf("%s: can't create application\n",argv[0]);
  154.             res = RETURN_FAIL;
  155.         }
  156.  
  157.         CloseLibrary(MUIMasterBase);
  158.     }
  159.     else
  160.     {
  161.         printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  162.         res = RETURN_ERROR;
  163.     }
  164.  
  165.     return res;
  166. }
  167.  
  168. /***********************************************************************/
  169.